package frame.UserPanel;


import frame.Main_Frame;
import model.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class Flights_Panel extends JPanel {

    public static String idNum=""; ;

    passenger_order po = new passenger_order();
    flight flight_object1 = new flight();
    public static String flight_num = "";
    public static String flight_order="";
    public static  int page = 1 ;
    public  int num ;
    String flight1_order ;
    String flight2_order ;
    String flight3_order;
    String flight4_order;


    String flight1 ;
    String flight2 ;
    String flight3 ;
    String flight4 ;


    public Flights_Panel() {


        idNum= Main_Frame.temp;

        //设置背景颜色
        setBackground(new Color(72,46,115));
        //设置初始面板
        JPanel panel = new JPanel();
        panel.setBackground(new Color(72,46,115));
        panel.setPreferredSize(new Dimension(1200,680));
        add(panel);
        panel.setLayout(null);

        JPanel panel0 = new JPanel();
        BorderLayout f1 = new BorderLayout();
        panel0.setLayout(f1);
        panel0.setBounds(0,0,1200,100);
        panel0.setBackground(new Color(72, 46, 115));

        JLabel title = new JLabel("SELECT THE FLIGHTS YOU WILL BE CHECKING IN FOR",SwingConstants.CENTER);
        title.setFont(new Font(Font.DIALOG,Font.BOLD,30));//设置文字字体
        title.setForeground(Color.white);//设置文字的颜色
        title.setOpaque(true);
        title.setBackground(new Color(72,46,115));
        title.setPreferredSize(new Dimension(800,80));
        panel0.add(title,BorderLayout.CENTER);



        JLabel  leftButton_label = new JLabel();
        leftButton_label.setPreferredSize(new Dimension(100,80));
        BorderLayout f2 = new BorderLayout();
        leftButton_label.setLayout(f2);
        panel0.add(leftButton_label,BorderLayout.WEST);
        JLabel  rightButton_label = new JLabel();
        rightButton_label.setPreferredSize(new Dimension(100,80));
        BorderLayout f3 = new BorderLayout();
        rightButton_label.setLayout(f3);
        panel0.add(rightButton_label,BorderLayout.EAST);

        JButton jButtonNext = new JButton("NEXT");
        jButtonNext.setFont(new Font(Font.DIALOG,Font.BOLD,23));//设置文字字体
        jButtonNext.setForeground(Color.white);//设置文字的颜色
        jButtonNext.setBackground(new Color(100,100,100));

        JButton jButtonLast = new JButton("LAST");
        jButtonLast.setFont(new Font(Font.DIALOG,Font.BOLD,23));//设置文字字体
        jButtonLast.setForeground(Color.white);//设置文字的颜色
        jButtonLast.setBackground(new Color(100,100,100));


        rightButton_label.add(jButtonNext,BorderLayout.CENTER);
        leftButton_label.add(jButtonLast,BorderLayout.CENTER);

        //String id_num = "360124200102040017";//临时添加测试使用的身份证号码


        num =po.orderNum(idNum);

        if(num>2) {
            jButtonNext.setVisible(true);
        }
        if(num<=2){
            jButtonNext.setVisible(false);
        }
        jButtonLast.setVisible(false);



        flight1_order = po.findOrder(idNum,1);
        flight1 = flight_object1.findFlight(flight1_order);

        JPanel panel1 = new JPanel();
        panel1.setBounds(150,120,900,220);
        panel1.setBackground(new Color(72,46,20));

        GridBagLayout gbl1 = new GridBagLayout();
        GridBagConstraints gbc1 = new GridBagConstraints();
        panel1.setLayout(gbl1);
        gbc1.fill=GridBagConstraints.BOTH;


        BorderLayout f11 = new BorderLayout();
        JPanel panel1_11 = new JPanel(f11);
        JLabel label1_11 = new JLabel("FLIGHT 1",SwingConstants.CENTER);
        label1_11.setPreferredSize(new Dimension(135,66));
        label1_11.setFont(new Font(Font.DIALOG,Font.PLAIN,28));//设置文字字体
        label1_11.setForeground(Color.white);//设置文字的颜色
        label1_11.setOpaque(true);
        label1_11.setBackground(new Color(220 ,66, 75));
        panel1_11.add(label1_11,BorderLayout.CENTER);
        gbc1.weightx=0.15;    // 指定组件的分配区域
        gbc1.weighty=0.3;
        gbc1.gridwidth=1;
        gbc1.gridheight=1;
        gbc1.gridx=0;
        gbc1.gridy=0;
        gbl1.setConstraints(panel1_11,gbc1);
        panel1.add(panel1_11);

        eachFlight ef1 = new eachFlight();

        BorderLayout f12 = new BorderLayout();
        JPanel panel1_12 = new JPanel(f12);

        String flight1_company= ef1.COMPANY(flight1);
        String flight1_boardingTime= ef1.boardingTime(flight1);
        String flight1_gate= ef1.GATE(flight1);
        JLabel label1_12 = new JLabel(flight1+" "+flight1_company+"         "+"BOARDING TIME  "+flight1_boardingTime+"         "+"GATE "+flight1_gate,SwingConstants.CENTER);
        label1_12.setPreferredSize(new Dimension(765,66));
        label1_12.setFont(new Font(Font.DIALOG,Font.BOLD,20));//设置文字字体
        label1_12.setForeground(Color.white);//设置文字的颜色
        label1_12.setOpaque(true);
        label1_12.setBackground(new Color(56, 53, 53));
        panel1_12.add(label1_12,BorderLayout.CENTER);
        gbc1.weightx=0.85;    // 指定组件的分配区域
        gbc1.weighty=0.3;
        gbc1.gridwidth=2;
        gbc1.gridheight=1;
        gbc1.gridx=1;
        gbc1.gridy=0;
        gbl1.setConstraints(panel1_12,gbc1);
        panel1.add(panel1_12);

        BorderLayout f21 =new BorderLayout();
        JPanel panel1_21 = new JPanel(f21);
        JLabel label1_21 = new JLabel();
        label1_21.setPreferredSize(new Dimension(135,154));
        label1_21.setOpaque(true);
        label1_21.setBackground(new Color(213, 213, 12));
        panel1_21.add(label1_21,BorderLayout.CENTER);
        gbc1.weightx=0.15;    // 指定组件的分配区域
        gbc1.weighty=0.7;
        gbc1.gridwidth=1;
        gbc1.gridheight=1;
        gbc1.gridx=0;
        gbc1.gridy=1;
        gbl1.setConstraints(panel1_21,gbc1);
        panel1.add(panel1_21);

        BorderLayout f22 = new BorderLayout();
        JPanel panel1_22 = new JPanel(f22);
        JLabel label1_22 = new JLabel();
        label1_22.setPreferredSize(new Dimension(315,154));
        label1_22.setOpaque(true);
        label1_22.setBackground(new Color(6, 39, 206));
        panel1_22.add(label1_22,BorderLayout.CENTER);
        gbc1.weightx=0.35;    // 指定组件的分配区域
        gbc1.weighty=0.7;
        gbc1.gridwidth=1;
        gbc1.gridheight=1;
        gbc1.gridx=1;
        gbc1.gridy=1;
        gbl1.setConstraints(panel1_22,gbc1);
        panel1.add(panel1_22);


        JPanel panel1_23 = new JPanel();
        panel1_23.setPreferredSize(new Dimension(450,154));
        gbc1.weightx=0.5;    // 指定组件的分配区域
        gbc1.weighty=0.7;
        gbc1.gridwidth=1;
        gbc1.gridheight=1;
        gbc1.gridx=2;
        gbc1.gridy=1;
        gbl1.setConstraints(panel1_23,gbc1);
        panel1.add(panel1_23);

        GridBagLayout gbl1_small = new GridBagLayout();
        GridBagConstraints gbc1_small = new GridBagConstraints();
        panel1_23.setLayout(gbl1_small);
        gbc1_small.fill=GridBagConstraints.BOTH;

        String flight1_departure = ef1.DEPARTURE(flight1);
        JLabel label1_2311 = new JLabel(flight1_departure,SwingConstants.CENTER);
        label1_2311.setPreferredSize(new Dimension(180,66));
        label1_2311.setFont(new Font(Font.DIALOG,Font.BOLD,18));//设置文字字体
        label1_2311.setForeground(Color.black);//设置文字的颜色
        label1_2311.setOpaque(true);
        label1_2311.setBackground(new Color(245, 240, 240));
        gbc1_small.weightx=0.4;    // 指定组件的分配区域
        gbc1_small.weighty=0.4;
        gbc1_small.gridwidth=1;
        gbc1_small.gridheight=1;
        gbc1_small.gridx=0;
        gbc1_small.gridy=0;
        gbl1_small.setConstraints(label1_2311,gbc1_small);
        panel1_23.add(label1_2311);

        String flight1_departs = ef1.DEPARTS(flight1);
        JLabel label1_2312 = new JLabel("DEPARTS:"+flight1_departs,SwingConstants.CENTER);
        label1_2312.setPreferredSize(new Dimension(270,66));
        label1_2312.setFont(new Font(Font.DIALOG,Font.BOLD,18));//设置文字字体
        label1_2312.setForeground(Color.black);//设置文字的颜色
        label1_2312.setOpaque(true);
        label1_2312.setBackground(new Color(233 ,233, 233));
        gbc1_small.weightx=0.6;    // 指定组件的分配区域
        gbc1_small.weighty=0.4;
        gbc1_small.gridwidth=1;
        gbc1_small.gridheight=1;
        gbc1_small.gridx=1;
        gbc1_small.gridy=0;
        gbl1_small.setConstraints(label1_2312,gbc1_small);
        panel1_23.add(label1_2312);

        String flight1_destination = ef1.DESTINATION(flight1);
        JLabel label1_2321 = new JLabel(flight1_destination,SwingConstants.CENTER);
        label1_2321.setPreferredSize(new Dimension(180,66));
        label1_2321.setFont(new Font(Font.DIALOG,Font.BOLD,18));//设置文字字体
        label1_2321.setForeground(Color.black);//设置文字的颜色
        label1_2321.setOpaque(true);
        label1_2321.setBackground(new Color(245, 240, 240));
        gbc1_small.weightx=0.4;    // 指定组件的分配区域
        gbc1_small.weighty=0.4;
        gbc1_small.gridwidth=1;
        gbc1_small.gridheight=1;
        gbc1_small.gridx=0;
        gbc1_small.gridy=1;
        gbl1_small.setConstraints(label1_2321,gbc1_small);
        panel1_23.add(label1_2321);

        String flight1_arrives = ef1.ARRIVES(flight1);
        JLabel label1_2322 = new JLabel("ARRIVES:"+flight1_arrives,SwingConstants.CENTER);
        label1_2322.setPreferredSize(new Dimension(270,66));
        label1_2322.setFont(new Font(Font.DIALOG,Font.BOLD,18));//设置文字字体
        label1_2322.setForeground(Color.black);//设置文字的颜色
        label1_2322.setOpaque(true);
        label1_2322.setBackground(new Color(213 ,213, 213));
        gbc1_small.weightx=0.6;    // 指定组件的分配区域
        gbc1_small.weighty=0.4;
        gbc1_small.gridwidth=1;
        gbc1_small.gridheight=1;
        gbc1_small.gridx=1;
        gbc1_small.gridy=1;
        gbl1_small.setConstraints(label1_2322,gbc1_small);
        panel1_23.add(label1_2322);

        String flight1_delay = ef1.DELAY(flight1);
        if (flight1_delay.equals("1")) {
            JLabel label1_233 = new JLabel("ON TIME", SwingConstants.CENTER);
            label1_233.setPreferredSize(new Dimension(270, 66));
            label1_233.setFont(new Font(Font.DIALOG, Font.BOLD, 21));//设置文字字体
            label1_233.setForeground(Color.white);//设置文字的颜色
            label1_233.setOpaque(true);
            label1_233.setBackground(new Color(104, 210, 128));
            gbc1_small.weightx=1;    // 指定组件的分配区域
            gbc1_small.weighty=0.2;
            gbc1_small.gridwidth=2;
            gbc1_small.gridheight=1;
            gbc1_small.gridx=0;
            gbc1_small.gridy=2;
            gbl1_small.setConstraints(label1_233,gbc1_small);
            panel1_23.add(label1_233);
        }
        if (flight1_delay.equals("0")) {
            JLabel label1_233 = new JLabel("DELAY", SwingConstants.CENTER);
            label1_233.setPreferredSize(new Dimension(270, 66));
            label1_233.setFont(new Font(Font.DIALOG, Font.BOLD, 21));//设置文字字体
            label1_233.setForeground(Color.white);//设置文字的颜色
            label1_233.setOpaque(true);
            label1_233.setBackground(new Color(222, 227, 108));
            gbc1_small.weightx=1;    // 指定组件的分配区域
            gbc1_small.weighty=0.2;
            gbc1_small.gridwidth=2;
            gbc1_small.gridheight=1;
            gbc1_small.gridx=0;
            gbc1_small.gridy=2;
            gbl1_small.setConstraints(label1_233,gbc1_small);
            panel1_23.add(label1_233);
        }


        JButton button1 = new JButton();
        button1.setBackground(new Color(96 ,84, 146));
        panel1_21.add(button1);

        String image_name1= ef1.IMG(flight1);
        ImageIcon image1 = new ImageIcon("resource/"+image_name1);
        image1.setImage(image1.getImage().getScaledInstance(315,154,Image.SCALE_DEFAULT));
        label1_22.setIcon(image1);
        label1_22.setSize(315,154);

        JPanel panel2 = new JPanel();
        panel2.setBounds(150, 360, 900, 220);
        panel2.setBackground(new Color(20, 20, 115));
        JButton button2 = new JButton();
        button2.setBackground(new Color(96 ,84, 146));
        if(num>=2) {

            flight flight_object2 = new flight();
            flight2_order = po.findOrder(idNum,2);
            flight2 = flight_object2.findFlight(flight2_order);

            GridBagLayout gbl2 = new GridBagLayout();
            GridBagConstraints gbc2 = new GridBagConstraints();
            panel2.setLayout(gbl2);
            gbc2.fill = GridBagConstraints.BOTH;


            BorderLayout f2_11 = new BorderLayout();
            JPanel panel2_11 = new JPanel(f2_11);
            JLabel label2_11 = new JLabel("FLIGHT 2", SwingConstants.CENTER);
            label2_11.setPreferredSize(new Dimension(135, 66));
            label2_11.setFont(new Font(Font.DIALOG, Font.PLAIN, 28));//设置文字字体
            label2_11.setForeground(Color.white);//设置文字的颜色
            label2_11.setOpaque(true);
            label2_11.setBackground(new Color(220 ,66, 75));
            panel2_11.add(label2_11, BorderLayout.CENTER);
            gbc2.weightx = 0.15;    // 指定组件的分配区域
            gbc2.weighty = 0.3;
            gbc2.gridwidth = 1;
            gbc2.gridheight = 1;
            gbc2.gridx = 0;
            gbc2.gridy = 0;
            gbl2.setConstraints(panel2_11, gbc2);
            panel2.add(panel2_11);


            BorderLayout f2_12 = new BorderLayout();
            JPanel panel2_12 = new JPanel(f2_12);
            eachFlight ef2 = new eachFlight();
            String flight2_company= ef2.COMPANY(flight2);
            String flight2_boardingTime= ef2.boardingTime(flight2);
            String flight2_gate= ef2.GATE(flight2);
            JLabel label2_12 = new JLabel(flight2+" "+flight1_company+"         "+"BOARDING TIME  "+flight2_boardingTime+"         "+"GATE "+flight2_gate,SwingConstants.CENTER);
            label2_12.setPreferredSize(new Dimension(765, 66));
            label2_12.setFont(new Font(Font.DIALOG, Font.BOLD, 20));//设置文字字体
            label2_12.setForeground(Color.white);//设置文字的颜色
            label2_12.setOpaque(true);
            label2_12.setBackground(new Color(56, 53, 53));
            panel2_12.add(label2_12, BorderLayout.CENTER);
            gbc2.weightx = 0.85;    // 指定组件的分配区域
            gbc2.weighty = 0.3;
            gbc2.gridwidth = 2;
            gbc2.gridheight = 1;
            gbc2.gridx = 1;
            gbc2.gridy = 0;
            gbl2.setConstraints(panel2_12, gbc2);
            panel2.add(panel2_12);

            BorderLayout f2_21 = new BorderLayout();
            JPanel panel2_21 = new JPanel(f2_21);
            JLabel label2_21 = new JLabel();
            label2_21.setPreferredSize(new Dimension(135, 154));
            label2_21.setOpaque(true);
            label2_21.setBackground(new Color(213, 213, 12));
            panel2_21.add(label2_21, BorderLayout.CENTER);
            gbc2.weightx = 0.15;    // 指定组件的分配区域
            gbc2.weighty = 0.7;
            gbc2.gridwidth = 1;
            gbc2.gridheight = 1;
            gbc2.gridx = 0;
            gbc2.gridy = 1;
            gbl2.setConstraints(panel2_21, gbc2);
            panel2.add(panel2_21);

            BorderLayout f2_22 = new BorderLayout();
            JPanel panel2_22 = new JPanel(f2_22);
            JLabel label2_22 = new JLabel();
            label2_22.setPreferredSize(new Dimension(315, 154));
            label2_22.setOpaque(true);
            label2_22.setBackground(new Color(6, 39, 206));
            panel2_22.add(label2_22, BorderLayout.CENTER);
            gbc2.weightx = 0.35;    // 指定组件的分配区域
            gbc2.weighty = 0.7;
            gbc2.gridwidth = 1;
            gbc2.gridheight = 1;
            gbc2.gridx = 1;
            gbc2.gridy = 1;
            gbl2.setConstraints(panel2_22, gbc2);
            panel2.add(panel2_22);


            JPanel panel2_23 = new JPanel();
            panel2_23.setPreferredSize(new Dimension(450, 154));
            gbc2.weightx = 0.5;    // 指定组件的分配区域
            gbc2.weighty = 0.7;
            gbc2.gridwidth = 1;
            gbc2.gridheight = 1;
            gbc2.gridx = 2;
            gbc2.gridy = 1;
            gbl2.setConstraints(panel2_23, gbc2);
            panel2.add(panel2_23);

            GridBagLayout gbl2_small = new GridBagLayout();
            GridBagConstraints gbc2_small = new GridBagConstraints();
            panel2_23.setLayout(gbl2_small);
            gbc2_small.fill = GridBagConstraints.BOTH;

            String flight2_departure= ef2.DEPARTURE(flight2);
            JLabel label2_2311 = new JLabel(flight2_departure, SwingConstants.CENTER);
            label2_2311.setPreferredSize(new Dimension(180, 66));
            label2_2311.setFont(new Font(Font.DIALOG, Font.BOLD, 18));//设置文字字体
            label2_2311.setForeground(Color.black);//设置文字的颜色
            label2_2311.setOpaque(true);
            label2_2311.setBackground(new Color(245, 240, 240));
            gbc2_small.weightx = 0.4;    // 指定组件的分配区域
            gbc2_small.weighty = 0.4;
            gbc2_small.gridwidth = 1;
            gbc2_small.gridheight = 1;
            gbc2_small.gridx = 0;
            gbc2_small.gridy = 0;
            gbl2_small.setConstraints(label2_2311, gbc2_small);
            panel2_23.add(label2_2311);

            String flight2_departs= ef2.DEPARTS(flight2);
            JLabel label2_2312 = new JLabel("DEPARTS:"+flight2_departs, SwingConstants.CENTER);
            label2_2312.setPreferredSize(new Dimension(270, 66));
            label2_2312.setFont(new Font(Font.DIALOG, Font.BOLD, 18));//设置文字字体
            label2_2312.setForeground(Color.black);//设置文字的颜色
            label2_2312.setOpaque(true);
            label2_2312.setBackground(new Color(233 ,233, 233));
            gbc2_small.weightx = 0.6;    // 指定组件的分配区域
            gbc2_small.weighty = 0.4;
            gbc2_small.gridwidth = 1;
            gbc2_small.gridheight = 1;
            gbc2_small.gridx = 1;
            gbc2_small.gridy = 0;
            gbl2_small.setConstraints(label2_2312, gbc2_small);
            panel2_23.add(label2_2312);

            String flight2_destination= ef2.DESTINATION(flight2);
            JLabel label2_2321 = new JLabel(flight2_destination, SwingConstants.CENTER);
            label2_2321.setPreferredSize(new Dimension(180, 66));
            label2_2321.setFont(new Font(Font.DIALOG, Font.BOLD, 18));//设置文字字体
            label2_2321.setForeground(Color.black);//设置文字的颜色
            label2_2321.setOpaque(true);
            label2_2321.setBackground(new Color(245, 240, 240));
            gbc2_small.weightx = 0.4;    // 指定组件的分配区域
            gbc2_small.weighty = 0.4;
            gbc2_small.gridwidth = 1;
            gbc2_small.gridheight = 1;
            gbc2_small.gridx = 0;
            gbc2_small.gridy = 1;
            gbl2_small.setConstraints(label2_2321, gbc2_small);
            panel2_23.add(label2_2321);

            String flight2_arrives= ef2.ARRIVES(flight2);
            JLabel label2_2322 = new JLabel("ARRIVES:"+flight2_arrives, SwingConstants.CENTER);
            label2_2322.setPreferredSize(new Dimension(270, 66));
            label2_2322.setFont(new Font(Font.DIALOG, Font.BOLD, 18));//设置文字字体
            label2_2322.setForeground(Color.black);//设置文字的颜色
            label2_2322.setOpaque(true);
            label2_2322.setBackground(new Color(213 ,213, 213));
            gbc2_small.weightx = 0.6;    // 指定组件的分配区域
            gbc2_small.weighty = 0.4;
            gbc2_small.gridwidth = 1;
            gbc2_small.gridheight = 1;
            gbc2_small.gridx = 1;
            gbc2_small.gridy = 1;
            gbl2_small.setConstraints(label2_2322, gbc2_small);
            panel2_23.add(label2_2322);

            String flight2_delay= ef2.DELAY(flight2);
            if(flight2_delay.equals("1")) {
                JLabel label2_233 = new JLabel("ON TIME", SwingConstants.CENTER);
                label2_233.setPreferredSize(new Dimension(270, 66));
                label2_233.setFont(new Font(Font.DIALOG, Font.BOLD, 21));//设置文字字体
                label2_233.setForeground(Color.white);//设置文字的颜色
                label2_233.setOpaque(true);
                label2_233.setBackground(new Color(104, 210, 128));
                gbc2_small.weightx = 1;    // 指定组件的分配区域
                gbc2_small.weighty = 0.2;
                gbc2_small.gridwidth = 2;
                gbc2_small.gridheight = 1;
                gbc2_small.gridx = 0;
                gbc2_small.gridy = 2;
                gbl2_small.setConstraints(label2_233, gbc2_small);
                panel2_23.add(label2_233);
            }
            if(flight2_delay.equals("0")){
                JLabel label2_233 = new JLabel("DELAYED", SwingConstants.CENTER);
                label2_233.setPreferredSize(new Dimension(270, 66));
                label2_233.setFont(new Font(Font.DIALOG, Font.BOLD, 21));//设置文字字体
                label2_233.setForeground(Color.white);//设置文字的颜色
                label2_233.setOpaque(true);
                label2_233.setBackground(new Color(222, 227, 108));
                gbc2_small.weightx = 1;    // 指定组件的分配区域
                gbc2_small.weighty = 0.2;
                gbc2_small.gridwidth = 2;
                gbc2_small.gridheight = 1;
                gbc2_small.gridx = 0;
                gbc2_small.gridy = 2;
                gbl2_small.setConstraints(label2_233, gbc2_small);
                panel2_23.add(label2_233);
            }


            panel2_21.add(button2);

            String image_name2= ef2.IMG(flight2);
            ImageIcon image2 = new ImageIcon("resource/"+image_name2);
            image2.setImage(image2.getImage().getScaledInstance(315, 154, Image.SCALE_DEFAULT));
            label2_22.setIcon(image2);
            label2_22.setSize(315, 154);

            panel.add(panel2);
        }

        JPanel panel3 = new JPanel();
        JButton button3 = new JButton();
        button3.setBackground(new Color(96 ,84, 146));

        if(num>=3) {

            flight flight_object3 = new flight();
            flight3_order = po.findOrder(idNum,3);
            flight3 = flight_object3.findFlight(flight3_order);

            panel3.setBounds(150,120,900,220);
            panel3.setBackground(new Color(72,46,20));

            GridBagLayout gbl3 = new GridBagLayout();
            GridBagConstraints gbc3 = new GridBagConstraints();
            panel3.setLayout(gbl3);
            gbc3.fill=GridBagConstraints.BOTH;


            BorderLayout f3_11 = new BorderLayout();
            JPanel panel3_11 = new JPanel(f3_11);
            JLabel label3_11 = new JLabel("FLIGHT 3",SwingConstants.CENTER);
            label3_11.setPreferredSize(new Dimension(135,66));
            label3_11.setFont(new Font(Font.DIALOG,Font.PLAIN,28));//设置文字字体
            label3_11.setForeground(Color.white);//设置文字的颜色
            label3_11.setOpaque(true);
            label3_11.setBackground(new Color(220 ,66, 75));
            panel3_11.add(label3_11,BorderLayout.CENTER);
            gbc3.weightx=0.15;    // 指定组件的分配区域
            gbc3.weighty=0.3;
            gbc3.gridwidth=1;
            gbc3.gridheight=1;
            gbc3.gridx=0;
            gbc3.gridy=0;
            gbl3.setConstraints(panel3_11,gbc3);
            panel3.add(panel3_11);

            eachFlight ef3 = new eachFlight();

            BorderLayout f3_12 = new BorderLayout();
            JPanel panel3_12 = new JPanel(f3_12);

            String flight3_company= ef3.COMPANY(flight3);
            String flight3_boardingTime= ef3.boardingTime(flight3);
            String flight3_gate= ef3.GATE(flight3);
            JLabel label3_12 = new JLabel(flight3+" "+flight3_company+"         "+"BOARDING TIME  "+flight3_boardingTime+"         "+"GATE"+flight3_gate,SwingConstants.CENTER);
            label3_12.setPreferredSize(new Dimension(765,66));
            label3_12.setFont(new Font(Font.DIALOG,Font.BOLD,23));//设置文字字体
            label3_12.setForeground(Color.white);//设置文字的颜色
            label3_12.setOpaque(true);
            label3_12.setBackground(new Color(56, 53, 53));
            panel3_12.add(label3_12,BorderLayout.CENTER);
            gbc3.weightx=0.85;    // 指定组件的分配区域
            gbc3.weighty=0.3;
            gbc3.gridwidth=2;
            gbc3.gridheight=1;
            gbc3.gridx=1;
            gbc3.gridy=0;
            gbl3.setConstraints(panel3_12,gbc3);
            panel3.add(panel3_12);

            BorderLayout f3_21 =new BorderLayout();
            JPanel panel3_21 = new JPanel(f3_21);
            JLabel label3_21 = new JLabel();
            label3_21.setPreferredSize(new Dimension(135,154));
            label3_21.setOpaque(true);
            label3_21.setBackground(new Color(213, 213, 12));
            panel3_21.add(label3_21,BorderLayout.CENTER);
            gbc3.weightx=0.15;    // 指定组件的分配区域
            gbc3.weighty=0.7;
            gbc3.gridwidth=1;
            gbc3.gridheight=1;
            gbc3.gridx=0;
            gbc3.gridy=1;
            gbl3.setConstraints(panel3_21,gbc3);
            panel3.add(panel3_21);

            BorderLayout f3_22 = new BorderLayout();
            JPanel panel3_22 = new JPanel(f3_22);
            JLabel label3_22 = new JLabel();
            label3_22.setPreferredSize(new Dimension(315,154));
            label3_22.setOpaque(true);
            label3_22.setBackground(new Color(6, 39, 206));
            panel3_22.add(label3_22,BorderLayout.CENTER);
            gbc3.weightx=0.35;    // 指定组件的分配区域
            gbc3.weighty=0.7;
            gbc3.gridwidth=1;
            gbc3.gridheight=1;
            gbc3.gridx=1;
            gbc3.gridy=1;
            gbl3.setConstraints(panel3_22,gbc3);
            panel3.add(panel3_22);


            JPanel panel3_23 = new JPanel();
            panel3_23.setPreferredSize(new Dimension(450,154));
            gbc3.weightx=0.5;    // 指定组件的分配区域
            gbc3.weighty=0.7;
            gbc3.gridwidth=1;
            gbc3.gridheight=1;
            gbc3.gridx=2;
            gbc3.gridy=1;
            gbl3.setConstraints(panel3_23,gbc3);
            panel3.add(panel3_23);

            GridBagLayout gbl3_small = new GridBagLayout();
            GridBagConstraints gbc3_small = new GridBagConstraints();
            panel3_23.setLayout(gbl3_small);
            gbc3_small.fill=GridBagConstraints.BOTH;

            String flight3_departure = ef3.DEPARTURE(flight3);
            JLabel label3_2311 = new JLabel(flight3_departure,SwingConstants.CENTER);
            label3_2311.setPreferredSize(new Dimension(180,66));
            label3_2311.setFont(new Font(Font.DIALOG,Font.BOLD,18));//设置文字字体
            label3_2311.setForeground(Color.black);//设置文字的颜色
            label3_2311.setOpaque(true);
            label3_2311.setBackground(new Color(245, 240, 240));
            gbc3_small.weightx=0.4;    // 指定组件的分配区域
            gbc3_small.weighty=0.4;
            gbc3_small.gridwidth=1;
            gbc3_small.gridheight=1;
            gbc3_small.gridx=0;
            gbc3_small.gridy=0;
            gbl3_small.setConstraints(label3_2311,gbc3_small);
            panel3_23.add(label3_2311);

            String flight3_departs = ef3.DEPARTS(flight3);
            JLabel label3_2312 = new JLabel("DEPARTS:"+flight3_departs,SwingConstants.CENTER);
            label3_2312.setPreferredSize(new Dimension(270,66));
            label3_2312.setFont(new Font(Font.DIALOG,Font.BOLD,18));//设置文字字体
            label3_2312.setForeground(Color.black);//设置文字的颜色
            label3_2312.setOpaque(true);
            label3_2312.setBackground(new Color(233 ,233, 233));
            gbc3_small.weightx=0.6;    // 指定组件的分配区域
            gbc3_small.weighty=0.4;
            gbc3_small.gridwidth=1;
            gbc3_small.gridheight=1;
            gbc3_small.gridx=1;
            gbc3_small.gridy=0;
            gbl3_small.setConstraints(label3_2312,gbc3_small);
            panel3_23.add(label3_2312);

            String flight3_destination = ef3.DESTINATION(flight3);
            JLabel label3_2321 = new JLabel(flight3_destination,SwingConstants.CENTER);
            label3_2321.setPreferredSize(new Dimension(180,66));
            label3_2321.setFont(new Font(Font.DIALOG,Font.BOLD,18));//设置文字字体
            label3_2321.setForeground(Color.black);//设置文字的颜色
            label3_2321.setOpaque(true);
            label3_2321.setBackground(new Color(245, 240, 240));
            gbc3_small.weightx=0.4;    // 指定组件的分配区域
            gbc3_small.weighty=0.4;
            gbc3_small.gridwidth=1;
            gbc3_small.gridheight=1;
            gbc3_small.gridx=0;
            gbc3_small.gridy=1;
            gbl3_small.setConstraints(label3_2321,gbc3_small);
            panel3_23.add(label3_2321);

            String flight3_arrives = ef3.ARRIVES(flight3);
            JLabel label3_2322 = new JLabel("ARRIVES:"+flight3_arrives,SwingConstants.CENTER);
            label3_2322.setPreferredSize(new Dimension(270,66));
            label3_2322.setFont(new Font(Font.DIALOG,Font.BOLD,18));//设置文字字体
            label3_2322.setForeground(Color.black);//设置文字的颜色
            label3_2322.setOpaque(true);
            label3_2322.setBackground(new Color(213 ,213, 213));
            gbc3_small.weightx=0.6;    // 指定组件的分配区域
            gbc3_small.weighty=0.4;
            gbc3_small.gridwidth=1;
            gbc3_small.gridheight=1;
            gbc3_small.gridx=1;
            gbc3_small.gridy=1;
            gbl3_small.setConstraints(label3_2322,gbc3_small);
            panel3_23.add(label3_2322);

            String flight3_delay = ef3.DELAY(flight3);
            if (flight3_delay.equals("1")) {
                JLabel label3_233 = new JLabel("ON TIME", SwingConstants.CENTER);
                label3_233.setPreferredSize(new Dimension(270, 66));
                label3_233.setFont(new Font(Font.DIALOG, Font.BOLD, 21));//设置文字字体
                label3_233.setForeground(Color.white);//设置文字的颜色
                label3_233.setOpaque(true);
                label3_233.setBackground(new Color(104, 210, 128));
                gbc3_small.weightx=1;    // 指定组件的分配区域
                gbc3_small.weighty=0.2;
                gbc3_small.gridwidth=2;
                gbc3_small.gridheight=1;
                gbc3_small.gridx=0;
                gbc3_small.gridy=2;
                gbl3_small.setConstraints(label3_233,gbc3_small);
                panel3_23.add(label3_233);
            }
            if (flight3_delay.equals("0")) {
                JLabel label3_233 = new JLabel("DELAY", SwingConstants.CENTER);
                label3_233.setPreferredSize(new Dimension(270, 66));
                label3_233.setFont(new Font(Font.DIALOG, Font.BOLD, 21));//设置文字字体
                label3_233.setForeground(Color.white);//设置文字的颜色
                label3_233.setOpaque(true);
                label3_233.setBackground(new Color(222, 227, 108));
                gbc3_small.weightx=1;    // 指定组件的分配区域
                gbc3_small.weighty=0.2;
                gbc3_small.gridwidth=2;
                gbc3_small.gridheight=1;
                gbc3_small.gridx=0;
                gbc3_small.gridy=2;
                gbl3_small.setConstraints(label3_233,gbc3_small);
                panel3_23.add(label3_233);
            }



            panel3_21.add(button3);

            String image_name3= ef3.IMG(flight3);
            ImageIcon image3 = new ImageIcon("resource/"+image_name3);
            image3.setImage(image3.getImage().getScaledInstance(315,154,Image.SCALE_DEFAULT));
            label3_22.setIcon(image3);
            label3_22.setSize(315,154);

            panel.add(panel3);
        }


        JPanel panel4 = new JPanel();
        JButton button4 = new JButton();
        button4.setBackground(new Color(96 ,84, 146));

        if(num>=4) {
            panel4.setBounds(150, 360, 900, 220);
            panel4.setBackground(new Color(20, 100, 115));



            flight flight_object4 = new flight();
            flight4_order = po.findOrder(idNum,4);
            flight4 = flight_object4.findFlight(flight4_order);

            GridBagLayout gbl4 = new GridBagLayout();
            GridBagConstraints gbc4 = new GridBagConstraints();
            panel4.setLayout(gbl4);
            gbc4.fill = GridBagConstraints.BOTH;


            BorderLayout f4_11 = new BorderLayout();
            JPanel panel4_11 = new JPanel(f4_11);
            JLabel label4_11 = new JLabel("FLIGHT 4", SwingConstants.CENTER);
            label4_11.setPreferredSize(new Dimension(135, 66));
            label4_11.setFont(new Font(Font.DIALOG, Font.PLAIN, 28));//设置文字字体
            label4_11.setForeground(Color.white);//设置文字的颜色
            label4_11.setOpaque(true);
            label4_11.setBackground(new Color(220 ,66, 75));
            panel4_11.add(label4_11, BorderLayout.CENTER);
            gbc4.weightx = 0.15;    // 指定组件的分配区域
            gbc4.weighty = 0.3;
            gbc4.gridwidth = 1;
            gbc4.gridheight = 1;
            gbc4.gridx = 0;
            gbc4.gridy = 0;
            gbl4.setConstraints(panel4_11, gbc4);
            panel4.add(panel4_11);


            BorderLayout f4_12 = new BorderLayout();
            JPanel panel4_12 = new JPanel(f4_12);
            eachFlight ef4 = new eachFlight();
            String flight4_company= ef4.COMPANY(flight4);
            String flight4_boardingTime= ef4.boardingTime(flight4);
            String flight4_gate= ef4.GATE(flight4);
            JLabel label4_12 = new JLabel(flight4+" "+flight4_company+"         "+"BOARDING TIME  "+flight4_boardingTime+"         "+"GATE "+flight4_gate,SwingConstants.CENTER);
            label4_12.setPreferredSize(new Dimension(765, 66));
            label4_12.setFont(new Font(Font.DIALOG, Font.BOLD, 20));//设置文字字体
            label4_12.setForeground(Color.white);//设置文字的颜色
            label4_12.setOpaque(true);
            label4_12.setBackground(new Color(56, 53, 53));
            panel4_12.add(label4_12, BorderLayout.CENTER);
            gbc4.weightx = 0.85;    // 指定组件的分配区域
            gbc4.weighty = 0.3;
            gbc4.gridwidth = 2;
            gbc4.gridheight = 1;
            gbc4.gridx = 1;
            gbc4.gridy = 0;
            gbl4.setConstraints(panel4_12, gbc4);
            panel4.add(panel4_12);

            BorderLayout f4_21 = new BorderLayout();
            JPanel panel4_21 = new JPanel(f4_21);
            JLabel label4_21 = new JLabel();
            label4_21.setPreferredSize(new Dimension(135, 154));
            label4_21.setOpaque(true);
            label4_21.setBackground(new Color(213, 213, 12));
            panel4_21.add(label4_21, BorderLayout.CENTER);
            gbc4.weightx = 0.15;    // 指定组件的分配区域
            gbc4.weighty = 0.7;
            gbc4.gridwidth = 1;
            gbc4.gridheight = 1;
            gbc4.gridx = 0;
            gbc4.gridy = 1;
            gbl4.setConstraints(panel4_21, gbc4);
            panel4.add(panel4_21);

            BorderLayout f4_22 = new BorderLayout();
            JPanel panel4_22 = new JPanel(f4_22);
            JLabel label4_22 = new JLabel();
            label4_22.setPreferredSize(new Dimension(315, 154));
            label4_22.setOpaque(true);
            label4_22.setBackground(new Color(6, 39, 206));
            panel4_22.add(label4_22, BorderLayout.CENTER);
            gbc4.weightx = 0.35;    // 指定组件的分配区域
            gbc4.weighty = 0.7;
            gbc4.gridwidth = 1;
            gbc4.gridheight = 1;
            gbc4.gridx = 1;
            gbc4.gridy = 1;
            gbl4.setConstraints(panel4_22, gbc4);
            panel4.add(panel4_22);


            JPanel panel4_23 = new JPanel();
            panel4_23.setPreferredSize(new Dimension(450, 154));
            gbc4.weightx = 0.5;    // 指定组件的分配区域
            gbc4.weighty = 0.7;
            gbc4.gridwidth = 1;
            gbc4.gridheight = 1;
            gbc4.gridx = 2;
            gbc4.gridy = 1;
            gbl4.setConstraints(panel4_23, gbc4);
            panel4.add(panel4_23);

            GridBagLayout gbl4_small = new GridBagLayout();
            GridBagConstraints gbc4_small = new GridBagConstraints();
            panel4_23.setLayout(gbl4_small);
            gbc4_small.fill = GridBagConstraints.BOTH;

            String flight4_departure= ef4.DEPARTURE(flight4);
            JLabel label4_2311 = new JLabel(flight4_departure, SwingConstants.CENTER);
            label4_2311.setPreferredSize(new Dimension(180, 66));
            label4_2311.setFont(new Font(Font.DIALOG, Font.BOLD, 18));//设置文字字体
            label4_2311.setForeground(Color.black);//设置文字的颜色
            label4_2311.setOpaque(true);
            label4_2311.setBackground(new Color(245, 240, 240));
            gbc4_small.weightx = 0.4;    // 指定组件的分配区域
            gbc4_small.weighty = 0.4;
            gbc4_small.gridwidth = 1;
            gbc4_small.gridheight = 1;
            gbc4_small.gridx = 0;
            gbc4_small.gridy = 0;
            gbl4_small.setConstraints(label4_2311, gbc4_small);
            panel4_23.add(label4_2311);

            String flight4_departs= ef4.DEPARTS(flight4);
            JLabel label4_2312 = new JLabel("DEPARTS:"+flight4_departs, SwingConstants.CENTER);
            label4_2312.setPreferredSize(new Dimension(270, 66));
            label4_2312.setFont(new Font(Font.DIALOG, Font.BOLD, 18));//设置文字字体
            label4_2312.setForeground(Color.black);//设置文字的颜色
            label4_2312.setOpaque(true);
            label4_2312.setBackground(new Color(233 ,233, 233));
            gbc4_small.weightx = 0.6;    // 指定组件的分配区域
            gbc4_small.weighty = 0.4;
            gbc4_small.gridwidth = 1;
            gbc4_small.gridheight = 1;
            gbc4_small.gridx = 1;
            gbc4_small.gridy = 0;
            gbl4_small.setConstraints(label4_2312, gbc4_small);
            panel4_23.add(label4_2312);

            String flight4_destination= ef4.DESTINATION(flight4);
            JLabel label4_2321 = new JLabel(flight4_destination, SwingConstants.CENTER);
            label4_2321.setPreferredSize(new Dimension(180, 66));
            label4_2321.setFont(new Font(Font.DIALOG, Font.BOLD, 18));//设置文字字体
            label4_2321.setForeground(Color.black);//设置文字的颜色
            label4_2321.setOpaque(true);
            label4_2321.setBackground(new Color(245, 240, 240));
            gbc4_small.weightx = 0.4;    // 指定组件的分配区域
            gbc4_small.weighty = 0.4;
            gbc4_small.gridwidth = 1;
            gbc4_small.gridheight = 1;
            gbc4_small.gridx = 0;
            gbc4_small.gridy = 1;
            gbl4_small.setConstraints(label4_2321, gbc4_small);
            panel4_23.add(label4_2321);

            String flight4_arrives= ef4.ARRIVES(flight4);
            JLabel label4_2322 = new JLabel("ARRIVES:"+flight4_arrives, SwingConstants.CENTER);
            label4_2322.setPreferredSize(new Dimension(270, 66));
            label4_2322.setFont(new Font(Font.DIALOG, Font.BOLD, 18));//设置文字字体
            label4_2322.setForeground(Color.black);//设置文字的颜色
            label4_2322.setOpaque(true);
            label4_2322.setBackground(new Color(213 ,213, 213));
            gbc4_small.weightx = 0.6;    // 指定组件的分配区域
            gbc4_small.weighty = 0.4;
            gbc4_small.gridwidth = 1;
            gbc4_small.gridheight = 1;
            gbc4_small.gridx = 1;
            gbc4_small.gridy = 1;
            gbl4_small.setConstraints(label4_2322, gbc4_small);
            panel4_23.add(label4_2322);

            String flight4_delay= ef4.DELAY(flight4);
            if(flight4_delay.equals("1")) {
                JLabel label4_233 = new JLabel("ON TIME", SwingConstants.CENTER);
                label4_233.setPreferredSize(new Dimension(270, 66));
                label4_233.setFont(new Font(Font.DIALOG, Font.BOLD, 21));//设置文字字体
                label4_233.setForeground(Color.white);//设置文字的颜色
                label4_233.setOpaque(true);
                label4_233.setBackground(new Color(104, 210, 128));
                gbc4_small.weightx = 1;    // 指定组件的分配区域
                gbc4_small.weighty = 0.2;
                gbc4_small.gridwidth = 2;
                gbc4_small.gridheight = 1;
                gbc4_small.gridx = 0;
                gbc4_small.gridy = 2;
                gbl4_small.setConstraints(label4_233, gbc4_small);
                panel4_23.add(label4_233);
            }
            if(flight4_delay.equals("0")){
                JLabel label4_233 = new JLabel("DELAYED", SwingConstants.CENTER);
                label4_233.setPreferredSize(new Dimension(270, 66));
                label4_233.setFont(new Font(Font.DIALOG, Font.BOLD, 21));//设置文字字体
                label4_233.setForeground(Color.white);//设置文字的颜色
                label4_233.setOpaque(true);
                label4_233.setBackground(new Color(222, 227, 108));
                gbc4_small.weightx = 1;    // 指定组件的分配区域
                gbc4_small.weighty = 0.2;
                gbc4_small.gridwidth = 2;
                gbc4_small.gridheight = 1;
                gbc4_small.gridx = 0;
                gbc4_small.gridy = 2;
                gbl4_small.setConstraints(label4_233, gbc4_small);
                panel4_23.add(label4_233);
            }


            panel4_21.add(button4);

            String image_name4= ef4.IMG(flight4);
            ImageIcon image4 = new ImageIcon("resource/"+image_name4);
            image4.setImage(image4.getImage().getScaledInstance(315, 154, Image.SCALE_DEFAULT));
            label4_22.setIcon(image4);
            label4_22.setSize(315, 154);

            panel.add(panel4);
        }

        panel.add(panel0);
        panel.add(panel1);




        panel3.setVisible(false);
        panel4.setVisible(false);

        flight_num=flight1;
        flight_order=flight1_order;
        button1.setBackground(new Color(104, 210, 128));
        button2.setBackground(new Color(96 ,84, 146));
        button3.setBackground(new Color(96 ,84, 146));
        button4.setBackground(new Color(96 ,84, 146));


        jButtonNext.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                if(page==1){
                    jButtonLast.setVisible(true);
                    jButtonNext.setVisible(false);
                    panel1.setVisible(false);
                    panel2.setVisible(false);
                    panel3.setVisible(true);
                    panel4.setVisible(true);
                    page++;
                }

            }
        });
        jButtonLast.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if(page==2){
                    jButtonNext.setVisible(true);
                    jButtonLast.setVisible(false);
                    panel3.setVisible(false);
                    panel4.setVisible(false);
                    panel1.setVisible(true);
                    panel2.setVisible(true);
                    page--;

                }

            }
        });

        button1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                button1.setBackground(new Color(104, 210, 128));
                button2.setBackground(new Color(96 ,84, 146));
                button3.setBackground(new Color(96 ,84, 146));
                button4.setBackground(new Color(96 ,84, 146));

                flight_num=flight1;
                flight_order=flight1_order;
                }


        });
        button2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                button2.setBackground(new Color(104, 210, 128));
                button1.setBackground(new Color(96 ,84, 146));
                button3.setBackground(new Color(96 ,84, 146));
                button4.setBackground(new Color(96 ,84, 146));
                flight_num=flight2;
                flight_order=flight2_order;
            }


        });

        button3.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                button3.setBackground(new Color(104, 210, 128));
                button1.setBackground(new Color(96 ,84, 146));
                button2.setBackground(new Color(96 ,84, 146));
                button4.setBackground(new Color(96 ,84, 146));
                flight_num=flight3;
                flight_order=flight3_order;
            }


        });

        button4.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                button4.setBackground(new Color(104, 210, 128));
                button1.setBackground(new Color(96 ,84, 146));
                button2.setBackground(new Color(96 ,84, 146));
                button3.setBackground(new Color(96 ,84, 146));
                flight_num=flight4;
                flight_order=flight4_order;
            }


        });

    }
}


